xl: correct argument parsing for some sub-commands.
authorIan Campbell <ian.campbell@citrix.com>
Tue, 24 Aug 2010 17:29:21 +0000 (18:29 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 24 Aug 2010 17:29:21 +0000 (18:29 +0100)
commit763cad85585b22925912f38f94ed89e18e115920
tree585ea7367f11bbf99db91bc2b8ba450003be9ff6
parent86316089e4611c19d3b53c16f0ace532ef24a576
xl: correct argument parsing for some sub-commands.

XL sub-commands are expected to parse their arguments relative to the
global variable "optind" rather than treating argc+argv as zero
based. This is because the argc+argv passed to sub-commands include
the entire original command line, not just the sub command specific bits.

Not all commands do this and they are therefore broken if the user
uses "xl -v command", correct such problems

dump-core:
  - did not handle "-h" option.

{network,network2,block}-{attach,list,detach} :
  - handled arguments without reference to optind
  - checked number of arguments before processing getopt loop,
    breaking "-h" option handling

An example of the breakage:
    # xl -v block-list d32-2
    Vdev  BE  handle state evt-ch ring-ref BE-path
    block-list is an invalid domain identifier
    51712 0   1      4     13     8        /local/domain/0/backend/vbd/1/

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/xl_cmdimpl.c
tools/libxl/xl_cmdtable.c